<?php
require('../conn.php');
require('../functions.php');
require('admin.php');
$uid = guolv($_GET['uid']);
$row = $mysql->query("select * from `user` where `id`='{$uid}}' limit 1");
$data = $row[0];
if ($_POST) {
    $uid = $_POST['uid'];
    $name = $_POST['name'];
    $password = $_POST['pass'];
    $pid = $_POST['pid'];
//    echo $pid;exit;
    $res = $mysql->execute("update `user` set `password`='{$password}',`name`='{$name}',`pid`='{$pid}' WHERE `id`={$uid}");
    if ($res) {
        echo "<script>alert('修改成功！')</script>";
        echo "<script>location.href='./edit_user.php?uid={$uid}'</script>";
    }
}
?>

<?php include('head.php') ?>
<link rel="stylesheet" href="../editor/themes/default/default.css"/>
<link rel="stylesheet" href="../editor/plugins/code/prettify.css"/>
<script src="<?php echo $jquerysite ?>" type="text/javascript"></script>
<script charset="utf-8" src="../editor/kindeditor.js"></script>
<script charset="utf-8" src="../editor/lang/zh_CN.js"></script>
<script charset="utf-8" src="../editor/plugins/code/prettify.js"></script>
<div class="container-fluid">

    <div class="row-fluid">
        <?php
        include('left.php'); ?>
        <div class="span9">
            <h1 class="page-title">用户修改</h1>

            <div class="well">
                <div id="myTabContent" class="tab-content">
                    <div class="tab-pane active in" id="home">
                        <form id="tab" action="edit_user.php" method="post">
                            <input type="hidden" name="uid" value="<?php echo $uid ?>">
                            <label>手机号：</label>
                            <input type="text" style="width:300px" name="phone" value="<?= $data['phone'] ?>" readonly>
                            <label>密码：</label>
                            <input type="text" style="width:300px" name="pass" value="<?= $data['password'] ?>">
                            <label>金币：</label>
                            <input type="text" style="width:300px" name="wx" value="<?= $data['gold'] ?>" readonly>
                            <label>积分：</label>
                            <input type="text" style="width:300px" name="money" value="<?= $data['total'] ?>" readonly>
                            <label>姓名：</label>
                            <input type="text" style="width:300px" name="name" value="<?= $data['name'] ?>">
                            <label>支付openid：</label>
                            <input type="text" style="width:300px" name="wxpay" value="<?= $data['wxpay'] ?>" readonly>
                            <label>徒弟数：</label>
                            <input type="text" style="width:300px" value="<?php
                            $studentNum = $mysql->query("select count(*) as num from `user` WHERE `pid`={$data['id']}");
                            echo $studentNum[0]['num'];
                            ?>" readonly>
                            <label>师傅UID</label>
                            <input type="text" style="width:300px" name="pid" value="<?= $data['pid'] ?>">
                            <label></label>
                            <button class="btn btn-primary"><i class="icon-save"></i> 修改</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>


</div>

<footer>
    <hr>

    <p class="pull-right"><!--power by right--></p>


    <p><!--power by --></p>
</footer>


<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="lib/bootstrap/js/bootstrap.js"></script>


</body>
</html>